package com.edu.edu.day25_homework.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.VideoView;

import com.edu.edu.day25_homework.bean.Movies;
import com.edu.edu.day25_homework.R;
import com.edu.edu.day25_homework.thread.loadImageTask;

/**
 * Created by Administrator on 2016/9/10.
 */
public class PlayVideoActivity extends AppCompatActivity{

    private VideoView mVideo;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.play_video);

        Log.d("TAG","playvideo>>>>>>>>>>");
        mVideo = (VideoView) findViewById(R.id.video_play);
        ImageView play_pimage = (ImageView) findViewById(R.id.play_image);
        TextView play_name_text = (TextView) findViewById(R.id.play_name_text);
        TextView play_highlight_text = (TextView) findViewById(R.id.play_highlight_text);
        TextView play_actors_text = (TextView) findViewById(R.id.play_actors_text);

        Intent intent = getIntent();
        Movies movie = (Movies) intent.getSerializableExtra("data");
        String movieName = movie.getName();
        String highlight = movie.getHighlight();
        String actors = movie.getActors();
        String logo = movie.getLogo();
        play_name_text.setText(movieName);
        play_highlight_text.setText(highlight);
        play_actors_text.setText(actors);

        new loadImageTask(play_pimage).execute(logo);

        Uri uri = Uri.parse(movie.getMobliepreview());
        Log.d("TAG","playvideo>>>>>>>>>>" + movie.getMobliepreview());
        Log.d("TAG","playvideo>>>>>>>>>>" + uri);
        mVideo.setMediaController(new MediaController(PlayVideoActivity.this));
        mVideo.setVideoURI(uri);
        mVideo.start();


    }
}
